#include <ez8.h>
#include <sio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fat.h"
#include "mmc.h"
#include "spi.h"
#include "fat.c"
#include "mmc.c"
#include "spi.c"

void main (void){
     char newdata[100];
     char filename[9]="000000";
     char err=0;
     
     init_uart(_UART1, _DEFFREQ, 9600);
     select_port(_UART1);
     printf("MMC UART TEST: UP IRC 2011\n");
     PDDD &= ~0x03;  //for LEDs
     PDDD |= 0x40;  //for PDs

     //if(!(PDIN & 0x40)){   //press PD6 before reset
          printf("Formatting...");
          format_to_fat16();
		  printf("Format Done.");
     //}

     printf("Filename: %s\n",filename);
     printf("Creating CSV File...\n");
     create_folder_file(filename, 1, 0);
     
     while(1){
          printf("%d, %f, %d, %s, \n", 13, 204.12,60, "ming");
          sprintf(newdata, "%d, %f, %d, %s, \n", 13, 204.12,"lol", "ming");
          err = writetommc(newdata,filename);
     }
}
